package com.dondedesigns.eh.controller.permission;

import com.dondedesigns.eh.persistence.Permissions;
import com.dondedesigns.eh.persistence.dao.PermissionDAO;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

public class Permission extends ActionSupport implements ModelDriven<Permissions> {
	
	private String permissionId;
	private Permissions permission;
	private PermissionDAO permissionDAO;

	@Override
	public String execute() throws Exception {
		if (permissionId == null || permissionId.isEmpty()) {
			permission = new Permissions();
		} else {
			permission = permissionDAO.find(Long.valueOf(permissionId));
		}
		return SUCCESS;
	}
	
	public void setPermissionId(String permissionId) {
		this.permissionId = permissionId;
	}
	
	public void setPermissionDAO(PermissionDAO permissionDAO) {
		this.permissionDAO = permissionDAO;
	}

	/*public Permissions getPermission() {
		return permission;
	}

	public void setPermission(Permissions permission) {
		this.permission = permission;
	}*/

	@Override
	public Permissions getModel() {
		return permission;
	}
}
